<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/9 0009
 * Time: 17:29
 */
namespace app\admin\model;
use think\Db;
use think\Exception;

class Tables
{
    /**创建表
     * @param $id
     * @return bool
     */
    static public function Creat($id){
        $tablesName = config('database.prefix').'bank'.$id;
        $sql = "create table $tablesName (id int(255)  primary key not null auto_increment,stem text(0),answer text(0),
right_key int(255),thinking text(0),challenge int(255),correct int(255),give int(255),coin int(255),create_time int(255)
,lanmu varchar(255),experience int(255),picture varchar(255),status int(20))
 engine=InnoDB charset=utf8";
        try{
            Db::execute($sql);
        }catch (Exception $e){
            return false;
        }

        return true;
    }

    /**删除题库
     * @param $tableName
     * @return bool
     */
    static public function del($tableName){
        $sql = "drop table $tableName";
        try{
            Db::execute($sql);
        }catch (Exception $e){
            return false;
        }
        return true;
    }
}